//学生信息管理
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

struct book {
	int index;
	char name[100];
	char writer[100];
	struct book *next;
};

struct book *head, *tail;

void input();
void view();
void search_name();
void search_writer();
void change_name();
void change_index();
void change();
void delete_name();
void delete_index();
void delete_();
void load_historical_data();

void input() {
	FILE *fp;
	struct book *q, *ptr;
	if ((fp = fopen("final.txt", "w")) == NULL) {
		printf("file open failed!\n");
		exit(-1);
	}
	q = (struct book*)malloc(sizeof(struct book));
	printf("please input your information!\n");
	printf("please input your index of book.\n");
	scanf("%d", &q->index);
	printf("please input your name of book.\n");
	scanf("%s", q->name);
	printf("please input your writer of book.\n");
	scanf("%s", q->writer);
	q->next = NULL;
	if (head == NULL) {
		head = q;
	} else {
		tail->next = q;
	}
	tail = q;
	for (ptr = head; ptr != NULL; ptr = ptr->next) {
		fprintf(fp, "%d | %s | %s", ptr->index, ptr->name, ptr->writer);
	}
	printf("information has been successfully added.!\n");
	if (fclose(fp)) {
		printf("cannont close ths file !\n");
		exit(0);
	}

}
